package com.xh.xyzp.controller;

import com.xh.xyzp.common.constant.UserContext;
import com.xh.xyzp.common.domain.vo.resp.ApiResult;
import com.xh.xyzp.common.domain.vo.resp.PageResp;
import com.xh.xyzp.domain.entity.Resume;
import com.xh.xyzp.domain.vo.ResumePageReq;
import com.xh.xyzp.domain.vo.ResumeSubmitReq;
import com.xh.xyzp.service.ResumeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "简历接口")
@RestController
@RequestMapping("/resume")
public class ResumeController {

    @Autowired
    private ResumeService resumeService;

    @ApiOperation("详细信息")
    @GetMapping("/info/{resumeId}")
    public ApiResult<Resume> getInfo(@PathVariable("resumeId") Long resumeId) {
        return ApiResult.success(resumeService.getInfo(resumeId));
    }

    @ApiOperation("查询自己的简历信息")
    @GetMapping("/info")
    public ApiResult<Resume> getInfoSelf() {
        return ApiResult.success(resumeService.getInfoByUserId(UserContext.getUser().getId()));
    }

    @ApiOperation("新增/编辑")
    @PostMapping("/submit")
    public ApiResult<Void> submit(@RequestBody ResumeSubmitReq req) {
        resumeService.submit(req);
        return ApiResult.success();
    }

    @ApiOperation("列表")
    @PostMapping("/list")
    public ApiResult<PageResp<Resume>> getList(@RequestBody ResumePageReq req) {
        return ApiResult.success(resumeService.getList(req));
    }
} 